<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=UTF-8" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>Dayve web</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link href="/common/css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/common/js/common.js"></script>
    <script type='text/javascript' src="/common/dwr/engine.js"></script>
    <script type='text/javascript' src="/common/dwr/util.js"></script>
    <script type='text/javascript' src='/dwr/interface/DayveService.js'></script>
    <script type="text/javascript">
        dwr.engine.setErrorHandler(handler);

        function handler(error) {
            alert("error: " + error);
        }

        // 입력받은 ID와 password로 로그인을 한다. 로그인이 성공하면 회원정보를 가져와서 출력한다.
        function jsLogin() {
            var TheForm = document.frm;

            if(trim(TheForm.search_id.value) == "") {
                alert("<spring:message code="index.alert1" />");
                TheForm.search_id.value = "";
                TheForm.password.value = "";
                TheForm.search_id.focus();
                return false;
            } else if(trim(TheForm.password.value) == "") {
                alert("<spring:message code="index.alert2" />");
                TheForm.search_id.value = "";
                TheForm.password.value = "";
                TheForm.search_id.focus();
                return false;
            } else {
                TheForm.id.value = TheForm.search_id.value;
                dwr.engine.setAsync(false);
                DayveService.logIn(TheForm.id.value, TheForm.password.value, function(result) {
                    if(result == "NON_EXIST") {
                        alert("<spring:message code="index.alert3" />");
                        TheForm.search_id.value = "";
                        TheForm.password.value = "";
                        TheForm.search_id.focus();
                        return false;
                    } else if(result == "FALSE") {
                        alert("<spring:message code="index.alert4" />");
                        TheForm.password.value = "";
                        TheForm.password.focus();
                        return false;
                    } else {
                        //TheForm.nextTarget.value = "memberInfo";	// page name(memberInfo.jsp)
                        TheForm.nextTarget.value = "intro";	// page name(intro.jsp)
//                        TheForm.setLocale.value = "kr";
                        TheForm.action = "./login.do";
                        TheForm.submit();
                    }
                });
                dwr.engine.setAsync(true);
                //jsGetCommentList();
            }
        }

        // Board List 페이지로 이동한다.
        function jsBoardList() {
            var TheForm = document.frm;
            TheForm.nextTarget.value = "list";	// page name
            TheForm.action = "./getBoardListBySearchword.do";
            TheForm.submit();
        }

        // Contact Member 페이지로 이동한다.
        function jsContactMember() {
            var TheForm = document.frm;
            TheForm.nextTarget.value = "contactMember";	// page name
            TheForm.action = "./contactMember.do";
            TheForm.submit();
        }


        function findId() {
            window.open('findId.do','','toolbar=no,menubar=no,location=no,height=200,width=500');
        }

        function findPassword() {
            //중앙위치 구해오기
            var LeftPosition=(screen.width-400)/2;
            var TopPosition=(screen.height-400)/2;
            window.open('findPassword.do','','toolbar=no,menubar=no,scrollbar=no,location=no,top='+TopPosition+', left='+LeftPosition+',height=400,width=400');
        }

    </script>
</head>


<body>
<div id="wrapper_login">
    <a href="intro.do"><img src="/images/intro/logo.gif" /></a>

    <div class="login_box">
        <form name="frm" method="POST" onsubmit="return false;">
            <input type="hidden" name="id" value=""/>
            <input type="hidden" name="nextTarget" value="">

            <div class="login_box02">
                <label><spring:message code="index.id" /></label>
                <input name="search_id" type="text" />
                <label><spring:message code="index.password" /></label>
                <input name="password" type="password" />
                <input type="image" src="/images/intro/btn_login.gif" class="login_button" alt="" style="margin: 0px; padding: 0px; border: 0px; width: 102px; height: 82px;" onclick="javascript:jsLogin()">
                <!-- <img src="/images/intro/btn_login.gif" class="login_button" onclick="javascript:jsLogin();"/>-->
                <a href="javascript:findPassword()"><img src="/images/intro/btn_pwsearch.gif" class="login_button02" /></a>
            </div>
        </form>
    </div>
    <p class="login_text">
        <spring:message code="index.text" /></p>
    <p class="login_text">
        <a href="https://play.google.com/store/apps/details?id=kr.pe.johnkim.dayve.activity&feature=search_result#?t=W251bGwsMSwxLDEsImtyLnBlLmpvaG5raW0uZGF5dmUuYWN0aXZpdHkiXQ.." target="_blank"><img src="/images/intro/btn_google02.gif" /></a>
        <a href="javascript:alert('준비 중 입니다. 가까운 시일 내에 만나보실 수 있습니다.')"><img src="/images/intro/btn_app02.gif" /></a>
    </p>
    <p class="login_copy">
        COPYRIGHT 2012 BETTERSOFT Inc ALL RIGHT RESERVED.
    </p>
</div>
</body>
</html>